﻿using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Solution.Application.Commands.Dtos;

namespace Solution.WebHost.Controllers
{
    [Authorize]
    [Route("api/user")]
    public class UserController : ControllerBase
    {
        private readonly IMediator _mediator;

        public UserController(IMediator mediator)
        {
            _mediator = mediator;
        }

        [HttpPost]
        [Route("add")]
        public async Task<IHandlerResult> GetUserAsync([FromBody] Application.Commands.Users.Add.Request request)
        {
            return await _mediator.Send(request);
        }

        [HttpPost]
        [Route("detail")]
        public async Task<IHandlerResult> GetUserAsync([FromBody] Application.Commands.Users.Detail.Request request)
        {
            return await _mediator.Send(request);
        }
    }
}